package lumis.portal.serialization.persistency.zip;

import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;


/**
 * {@link InputStream} wrapper that calls back the stream's source {@link ZipDirectory} when then stream is closed.  
 * @version $Revision: 6376 $ $Date: 2007-04-10 17:55:53 -0300 (Tue, 10 Apr 2007) $
 * @since 4.0.10
 */
class ZipDirectoryInputStream extends InputStream
{
	private Closeable streamClosingCallback;
	private InputStream is;
	
	public ZipDirectoryInputStream(InputStream is, Closeable streamClosingCallback)
	{
		this.is = is;
		this.streamClosingCallback = streamClosingCallback;
	}

	@Override
	public void close() throws IOException
	{
		is.close();
		streamClosingCallback.close();
	}

	@Override
	public int read() throws IOException
	{
		return is.read();
	}

	@Override
	public int available() throws IOException
	{
		return is.available();
	}

	@Override
	public synchronized void mark(int readlimit)
	{
		is.mark(readlimit);
	}

	@Override
	public boolean markSupported()
	{
		return is.markSupported();
	}

	@Override
	public int read(byte[] b, int off, int len) throws IOException
	{
		return is.read(b, off, len);
	}

	@Override
	public int read(byte[] b) throws IOException
	{
		return is.read(b);
	}

	@Override
	public synchronized void reset() throws IOException
	{
		is.reset();
	}

	@Override
	public long skip(long n) throws IOException
	{
		return is.skip(n);
	}
}
